package com.unity.notificationbackground;
import android.os.AsyncTask;

public class BackgroundNotificationTask extends AsyncTask<Integer, String, String> {
    private IBackgroundNotification _progressNotify;
    public BackgroundNotificationTask(IBackgroundNotification progressNotify) {
        super();
        _progressNotify = progressNotify;
    }

    @Override
    protected String doInBackground(Integer... integers) {
        try {
            while (true) {
                if (_progressNotify.NeedClose())
                {
                    AndroidBackgroundNotificationManager.GetInstance().CancelDisplayedNotification(_progressNotify.GetId());
                    Thread.sleep(1000);
                    continue;
                }
                if (!isCancelled())
                {
                    AndroidBackgroundNotificationManager.GetInstance().SendBackgroundNotification(_progressNotify);
                    Thread.sleep(1000);
                }else{
                    break;
                }
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
//        UnityNotificationManager.GetInstance().SendProgressNotification(_progressNotify);
        return "";
    }

    @Override
    protected void onProgressUpdate(String... values) {
        super.onProgressUpdate(values);
    }
}
